#include "BoxElement.hpp"

const float BoxElement::FRICTION = 0.9f;
const float BoxElement::RESTITUTION = 0.15f;

BoxElement::BoxElement(float x, float y, b2World* world) {
    b2BodyDef bodyDefinition;
    bodyDefinition.userData = this;
    bodyDefinition.position.Set(x, y);
    bodyDefinition.type = b2_dynamicBody;
    bodyDefinition.bullet = true;

    b2PolygonShape shape;
    shape.SetAsBox(0.5f, 0.5f);

    b2FixtureDef fixtureDefinition;
    fixtureDefinition.shape = &shape;
    fixtureDefinition.density = 20.0f;
    fixtureDefinition.friction = BoxElement::FRICTION;
    fixtureDefinition.restitution = BoxElement::RESTITUTION;

    this->body = world->CreateBody(&bodyDefinition);
    this->body->CreateFixture(&fixtureDefinition);
}

bool BoxElement::isBox() {
    return true;
}
